package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.BdMaterialMapper;
import com.ruoyi.system.service.IBdMaterialService;

/**
 * 物资物料基本信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-12-16
 */
@Service
public class BdMaterialServiceImpl implements IBdMaterialService 
{
    @Autowired
    private BdMaterialMapper bdMaterialMapper;

    @Override
    @DataSource(value = DataSourceType.YONGYOU)
    public List<SortVo> sortMaterial() {
        List<SortVo> sortVos = bdMaterialMapper.getAllSort();
        return sortVos;
    }

    @Override
    @DataSource(value = DataSourceType.YONGYOU)
    public SortVo sortById(String id) {
        SortVo sortVo = bdMaterialMapper.selectSortById(id);
        return sortVo;
    }

    @Override
    @DataSource(value = DataSourceType.YONGYOU)
    public List<MarterialVo> getMaterialList(RequestParam requestParam) {
        List<MarterialVo> materialList = bdMaterialMapper.getMaterialList(requestParam);
        for (MarterialVo marterialVo : materialList) {
            if (StringUtils.isEmpty(marterialVo.getPrice())){
                marterialVo.setPrice("18.8");
            }
            if (StringUtils.isEmpty(marterialVo.getTax())){
                marterialVo.setTax("0.1");
            }
        }
        return materialList;
    }

    @Override
    @DataSource(value = DataSourceType.YONGYOU)
    public BdMaterial getBdMaterialById(String id) {
        return bdMaterialMapper.getBdMaterialById(id);
    }

    @Override
    @DataSource(value = DataSourceType.YONGYOU)
    public int insertIcSapplyB(IcSapplyB icSapplyB) {
        return bdMaterialMapper.insertIcSapplyB(icSapplyB);
    }

    @Override
    @DataSource(value = DataSourceType.YONGYOU)
    public int insertIcSapplyH(IcSapplyH icSapplyH) {
        return bdMaterialMapper.insertIcSapplyH(icSapplyH);
    }

    @Override
    @DataSource(value = DataSourceType.YONGYOU)
    public List<SupplierVo> getAllSuppiler() {
        return bdMaterialMapper.getSupplier();
    }

    @Override
    @DataSource(value = DataSourceType.YONGYOU)
    public Integer selectTPurchaseStatus(String id) {
        return bdMaterialMapper.selectTPurchaseStatus(id);
    }

    @Override
    @DataSource(value = DataSourceType.YONGYOU)
    public String selectUserDev(String userId) {
        return bdMaterialMapper.selectUserDev(userId);
    }

    @Override
    @DataSource(value = DataSourceType.YONGYOU)
    public String selectPkGrop() {
        return bdMaterialMapper.selectPkGrop();
    }
}
